<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>

<html manifest="main.manifest">
<head>
  <script type="text/javascript" language="javascript" src="/javascript/eventdb.js"></script>
  <script type="text/javascript" language="javascript" src="/javascript/ajax.js"></script>
  <script type="text/javascript" language="javascript" src="/javascript/request.js"></script>
<link href="/iui/iuix.css" type="text/css" media="screen" rel="stylesheet">
<title>Events</title>
<meta user-scalable="0;" maximum-scale="1.0;" initial-scale="1.0;" name="viewport"content="width=320;"/>  
</head>
<%
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    if (user != null) {
%>




<body onload="getEventsFromDb();">
<p>
<div class="toolbar" id="eventListdiv">
        <h1 id="pageTitle">Events for <%= user.getNickname() %></h1>
        
        <input type="button" class="button leftButton" onclick="deleteEventTable();handleOnEventClick('/event/getUserEventsPhone/')" value="Update ">
<!--  <input type="button" class="button blueButton" onclick="deleteEventTable();" value="delete"> -->
<input type="button" class="button bluebutton" onclick="location.href='<%= userService.createLogoutURL(request.getRequestURI()) %>'" value="logout" >

 </div>
 
<ul id="eventList" title="Events" selected="true">

</ul>


<div class="toolbar" id="eventForm" style="display: none;">
       
    </div>
	<form id="searchForm"  class="dialog" method="post" action="/event/storeEventInstance/" style="display: none">
        <fieldset>
            <a class="button leftButton" type="cancel" onclick="showEventForm('cancel')"
			href="#">Cancel</a>
            <input type="submit" class="button blueButton" type="submit">
			<input type="text" style="display:none" name="eventName" id="eventName"
			value=""/>
			<input type="text" style="display:none" name="eventType" 
			value="single"/>
			  <label>Date :</label>
			 <input id="eventTimestamp" type="text" name="eventTimestamp" 
			 value=""/>
        </fieldset>
    </form>
    <%
    } else {
%>
<body>
<p>Please click here to 
<a href="<%= userService.createLoginURL(request.getRequestURI()) %>">Sign in</a>
</p>
<%
    }
%>

</body>
</html>